package com.yl.solution.entity;

import java.io.Serializable;
import java.sql.Blob;
import java.util.Date;

import javax.persistence.Basic;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.Lob;
import javax.persistence.ManyToOne;
import javax.persistence.SequenceGenerator;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;

@Entity(name = "Resolved_Problem")
public class Resolved_Problem implements Serializable {		// 已有问题表
	
	private static final long serialVersionUID = 7851049736199393443L;

	@Id
	@Column
	@GeneratedValue(strategy = GenerationType.SEQUENCE, // 使用sequence生成主键
	generator = "generator" // 引用下面名为gernator的生成策略
	)
	@SequenceGenerator(name = "generator", // 定义名为generator的生成策略
	allocationSize = 1, // 每次sequence加1
	sequenceName = "Resolved_Problem_seq" // 引用名为Resolved_Problem_seq的sequence
	)
	private int id; // 问题ID

	@Column(name = "title", length = 100)
	private String title; // 问题标题

	@Column(name = "sketch", length = 1000)
	private String sketch; // 问题简述

	@Lob
	@Basic(fetch = FetchType.LAZY)
	@Column(name = "problem_image", columnDefinition = "BLOB", nullable = true)
	private Blob problem_image; // 问题图片

	@Column(name = "text_solutions", length = 1000)
	private String text_solutions; // 解决方案文字

	@Lob
	@Basic(fetch = FetchType.LAZY)
	@Column(name = "pic_solutions", columnDefinition = "BLOB", nullable = true)
	private Blob pic_solutions; // 解决方案图片

	@Temporal(TemporalType.DATE)
	@Column(name = "resolution_time")
	private Date resolution_time; // 问题解决时间

	@Column(name = "search_frequency")
	private int search_frequency; // 问题搜索频率

	@ManyToOne()
	@JoinColumn(name = "user_id")
	private Users user; // 问题录入人（外键）

	@ManyToOne()
	@JoinColumn(name = "question_type_id")
	private Question_Type question_type; // 问题类型（外键）

	public int getId() {
		return id;
	}

	public void setId(int id) {
		this.id = id;
	}

	public String getTitle() {
		return title;
	}

	public void setTitle(String title) {
		this.title = title;
	}

	public String getSketch() {
		return sketch;
	}

	public void setSketch(String sketch) {
		this.sketch = sketch;
	}

	public Blob getProblem_image() {
		return problem_image;
	}

	public void setProblem_image(Blob problem_image) {
		this.problem_image = problem_image;
	}

	public String getText_solutions() {
		return text_solutions;
	}

	public void setText_solutions(String text_solutions) {
		this.text_solutions = text_solutions;
	}

	public Blob getPic_solutions() {
		return pic_solutions;
	}

	public void setPic_solutions(Blob pic_solutions) {
		this.pic_solutions = pic_solutions;
	}

	public Date getResolution_time() {
		return resolution_time;
	}

	public void setResolution_time(Date resolution_time) {
		this.resolution_time = resolution_time;
	}

	public int getSearch_frequency() {
		return search_frequency;
	}

	public void setSearch_frequency(int search_frequency) {
		this.search_frequency = search_frequency;
	}

	public Users getUser() {
		return user;
	}

	public void setUser(Users user) {
		this.user = user;
	}

	public Question_Type getQuestion_type() {
		return question_type;
	}

	public void setQuestion_type(Question_Type question_type) {
		this.question_type = question_type;
	}

}
